package com.baidu.fengchao.broad;

import com.baidu.fengchao.broad.action.UserAction;
import com.baidu.fengchao.broad.bo.Iface;
import com.baidu.fengchao.broad.bo.Link;
import com.baidu.fengchao.broad.bo.ProductType;
import com.baidu.fengchao.broad.bo.User;
import com.baidu.fengchao.broad.util.MD5Util;
import org.nutz.dao.Dao;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;

/**
 * Created with IntelliJ IDEA.
 * User: xiaojiangang
 * Date: 13-5-3
 * Time: 上午11:01
 */
public class SetUp implements Setup{
    @Override
    public void init(NutConfig nutConfig) {
        Dao dao = nutConfig.getIoc().get(Dao.class,"dao");
        dao.create(Link.class,false);
        dao.create(ProductType.class,false);
        dao.create(Iface.class,false);
        if(null != dao.create(User.class,false)){
            User user = new User();
            user.setPassword(MD5Util.getMD5("Asd123".getBytes()));
            user.setEmail("test@baidu.com");
            dao.insert(user);
        }
    }

    @Override
    public void destroy(NutConfig nutConfig) {
    }
}
